

let hostservlet="http://localhost:8080/projectfirst/"
$.ajaxSetup({
    async:false,
    xhrFields: {
        withCredentials: true
    }
})


$(function () {

    let app=new Vue({
        el:"#app",
        data:{
            plist:getproductall(""),
            imglist:getimgall(),
            hostservlet:hostservlet
        },
        methods:{
            selectBykey:function (key) {

               this.plist=getproductall(key)
            },
            getinfo:function (productid) {
                location.href="show.html?id="+productid

            }

        }

    })
})

function getproductall(key) {
    let temp;
    $.post(hostservlet+"productservlet",{"type":"select","key":key},function (data) {

        temp=data
    },"json")
    return temp
}

function getimgall() {
    let temp;
    $.getJSON(hostservlet+"productservlet",{"type":"selectimg"},function (data) {

        temp=data
    })
    return temp
}














